

public class Personalinfo{
	private String name;
	private String id;
	private int count;

	public Personalinfo(){
		name="nobody";
		id="N/A";
	}

/*
//method 1
	public synchronized void setNameAndID(String name,String id){
		this.name=name;
		this.id=id;

		if(!checkNameAndIDEqual()){
			System.out.println(count+":illegal name or ID");
		}
		count++;
	}
*/
//method 2
	public void setNameAndID(String name,String id){
		synchronized(this){
			this.name=name;
			this.id=id;

			if(!checkNameAndIDEqual()){
				System.out.println(count+":illegal name or ID");
			}
		}
		count++;
	}
	private boolean checkNameAndIDEqual(){
		return (name.charAt(0)==id.charAt(0))? true:false;
		
	}



}


